package com.zycfc.zsf.boot.mq.rabbitmq.destinations;

import java.util.*;
import org.springframework.amqp.core.*;

public final class BroadcastDestination extends FanoutDestination
{
    private boolean durable;
    private boolean autoDelete;
    private boolean exclusive;
    
    public BroadcastDestination(final Destination destination) {
        super(destination);
        this.durable = true;
        this.autoDelete = true;
        this.exclusive = true;
    }
    
    @Override
    public final FanoutExchange exchange() {
        if (null == this.exchange) {
            this.exchange = new FanoutExchange(this.exchangeName, this.durable, this.autoDelete);
        }
        return this.exchange;
    }
    
    @Override
    public final Queue queue() {
        if (null == this.queue) {
            final String queueNameNew = this.exchangeName + "." + this.queueName + "-" + UUID.randomUUID().toString().replaceAll("-", "");
            this.queue = new Queue(queueNameNew, this.durable, this.exclusive, this.autoDelete);
        }
        return this.queue;
    }
}
